package com.example.administrator.newjiajiesong.test;

import android.util.Log;

import com.example.administrator.newjiajiesong.JsonUtils;
import com.example.administrator.newjiajiesong.network.http.ApiUtils;
import com.example.administrator.newjiajiesong.network.http.ResponseBean;


import java.util.List;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import mlxy.utils.L;


/**
 * Created by: xudiwei
 * <p>
 * on: 2017/5/9.
 * <p>
 * 描述：：邀请消息Fragment的Presenter实现类
 */

public class InviteMessagePresenter extends BasePresenter<IInviteMessageView> implements IInviteMessagePresenter {
    private static final String TAG = "InviteMessagePresenter";


    public InviteMessagePresenter(IInviteMessageView view) {
        this.attach(view);
    }

    @Override
    public void getInviteMessageRefresh(final getstore inviteMessages) {

        ApiUtils.getApi()
                .getStore("cd485fd75d5315e9e803cbe44179214b")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new HttpObserver<ResponseBean>() {
                    @Override
                    public void onSuccess(ResponseBean allMessage) {
                        Log.d(TAG, "onSuccess: " + allMessage);
                        String s = JsonUtils.toJson(allMessage);
                        L.e("ssssss"+s);
                        getstore result = (getstore)allMessage.getResult();
                        IInviteMessageView view = getView();
                        getView().showTextview(result);
                    }

                    @Override
                    public void onFailed(int code, String msg) {
                        Log.d(TAG, "onFailed: " + msg);
                        if (null != getView()) {
                            getView().getMessageResult(false, false, msg);
                        }
                    }
                });


    }

    @Override
    public void getInviteMessageLoadMore(final List<CommunityMessageBean.MsgBean> inviteMessages) {

    }
}